#ifndef _SOCKET_
#define _SOCKET_

#include "InetAddress.h"

class Socket{
/*
    封装tcpsocketfd
*/
public:
    explicit Socket(int sockfd) : sockfd_(sockfd) { }
    ~Socket();

    inline int fd () const { return sockfd_; }
    void bindAddress(const InetAddress &localaddr);
    void listen();
    int accept(InetAddress *perraddr);
    void shutdownWrite();
    void setTcpNoDelay(bool on);
    void setReuseAddr(bool on);
    void setReusePort(bool on);
    void setKeepAlive(bool on);
private:
    const int sockfd_;  //一次性初始化后不再更改
};

#endif